package main

import "fmt"

func main()  {
	var str = "(){[]}([(]))"
	fmt.Println(testkuohao(str))
}

var M = map[string]string{
	")":"(",
	"}":"{",
	"]":"[",
}
func testkuohao(str string) bool {
	sli := []string{}
	for _,v :=range str {
		s := fmt.Sprintf("%c",v)

		if s == "(" || s == "{" || s == "[" {
			sli = append(sli,s)
			continue
		}

		if s == ")" || s == "}" || s == "]" {
			_,exist := M[s]
			if !exist || len(sli) <= 0 || sli[len(sli)-1] != M[s] {
				return false
			}
			sli = sli[:len(sli)-1]
		}
	}
	return len(sli) == 0
}
